/*
 * @Author: Lin Hongwei
 * @Date: 2022-10-06 16:01:12
 * @LastEditTime: 2022-10-31 18:45:24
 * @LastEditors: Lin Hongwei
 * @email: 1365755396@qq.com
 * @CSDN: https://blog.csdn.net/weixin_45429409
 * @Description: 自定义错误信息组件，接受任何类型
 */
import { Typography } from "antd";
const isError = (value: any): value is Error => value?.message; //将value强制指定为error类型
export const ErrorBox = ({ error }: { error: unknown }) => {
  if (!isError(error)) return null;
  return (
    <Typography.Text type="danger">
      {error.message || "网络错误"}
    </Typography.Text>
  );
};
